﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MaxStudio.Concrete.WebSite.Models.FunctionesModels>" %>
<%@ Import Namespace="MaxStudio.Concrete.Server.Dao" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Functiones
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <%--   <div style="background-color: #f5f5f5; margin:10px; border: thin solid  #ffd18c">
            sd
        </div>--%>
          
        <div>
            >>我的位置 >> 用户管理 >> 权限组管理
        </div>
        <div>
            <div id="tabs">
                <ul>
                    <li><a href="#tabs-1">功能介绍</a></li>
                    <li><a href="#tabs-2">权限组管理</a></li>
                </ul>
                <div id="tabs-1">
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
                    incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
                    exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
                <div id="tabs-2">
                    <div style="width: auto; margin: 10px;">
                        <p>
                            <a href="#" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin">
                            </span>添加权限组</a></p>
                        <!-- ui-dialog -->
                        <div id="dialog" title="权限组添加">
                            <p> 
                       <% using (Html.BeginForm("FunctionesGroup","FunctionItems")) {%>
                        <%= Html.ValidationSummary(true) %>
                                    <div style="  width:100%;">
                                           <div style="float:left; width:100%"> 
                                                  用户组名称 
                                                    <%= Html.TextBoxFor(model => model.GroupName) %>
                                                    <%= Html.ValidationMessageFor(model => model.GroupName) %>
                                            </div>
                                            <div style="float:left; width:100%; margin-top:20px;"> 
                                              <% List<tb_FunctionItem> objList = ViewData["FunctionItems"] as List<tb_FunctionItem>;%>  
                                                    <%
                                                        var dropList = new List<CheckBox>();
                                                        foreach (tb_FunctionItem FI in objList)
                                                        {
                                                            var dropItem = new CheckBox();
                                                            dropItem.Text = FI.Name.ToString(); %>
                                                    <%= Html.CheckBox("checkBox",new { id="myCheckBox" })%>
                                                    <%= Html.Encode(FI.Name)  %>
                                                    <%  } 
                                                    %>
                                            </div>
                                            <div style="float:left; width:100%; margin-top:20px; text-align:right;"> 
                                                <input type="submit" value="submit" />
                                                <input  type="reset" value="Reset" />
                                            </div>
                                    </div> 
                             <% } %>
                                    </p> 
                        </div>
                        
          
                <!-- Eidt ui-dialog -->
    	            <script  type="text/javascript"> 
     	                $.fx.speeds._default = 1000;
    	                $(function() {
    	                $("#Div1").dialog({
    	                autoOpen: false  
    	                    });

//     	                    $("#opener").click(function() {
//     	               //     $("#Div1").dialog("open");
    	                      //  return false;
//    	                    });
    	               // });
	                </script>
                    
                  <div id="Div1" title="ED">
                            <p> 
                      <%-- <% using (Html.BeginForm("GetDetailsFunctionesGroup","FunctionItems", FormMethod.Get)) {%>--%>
                       <% using (Html.BeginForm( ))  {%>    <%--修改事件--%>
                        <%= Html.ValidationSummary(true) %>
                                    <div style="  width:100%;">
                                           <div style="float:left; width:100%"> 
                                                  ss用户组名称 
                                                  ==
                                                     <%  List<tb_FunctionGroup> obj = ViewData["FunctionesModelsDetails"] as  List<tb_FunctionGroup>;%>  
                                                        <%
                                                            if (obj != null)
                                                            { %>
                                                                  <%= Html.TextArea(obj[0].GroupName.ToString ())  %>
                                                           <% }
                              
                                                        %>==
                                                     
                                            </div>
                                            <div style="float:left; width:100%; margin-top:20px;"> 
                                              <% List<tb_FunctionItem> objList = ViewData["FunctionItems"] as List<tb_FunctionItem>;%>  
                                                    <%
                                                        var dropList = new List<CheckBox>();
                                                        foreach (tb_FunctionItem FI in objList)
                                                        {
                                                            var dropItem = new CheckBox();
                                                            dropItem.Text = FI.Name.ToString(); %>
                                                    <%= Html.CheckBox("checkBox",new { id="myCheckBox" })%>
                                                    <%= Html.Encode(FI.Name)  %>
                                                    <%  } 
                                                    %>
                                            </div>
                                            <div style="float:left; width:100%; margin-top:20px; text-align:right;"> 
                                                <input type="submit" value="Edit" />
                                                <input  type="reset" value="Reset" />
                                            </div>
                                    </div> 
                             <% } %>
                                    </p> 
                        </div>      

                     <div> 
                     <table id="customers" style="display:none"></table>
         <script type="text/javascript">
             $("#customers").flexigrid(
             {
                 url: '/FunctionItems/FlexigridList',
                 dataType: 'json',

                 colModel: [
                            { display: 'ID', name: 'Id', width: 40, sortable: true, align: 'left' },
                            { display: 'Name', name: 'Name' + 'ss', width: 100, sortable: true, align: 'left' } 
                             
                    ],
                 buttons: [
                                { name: 'add', displayname: '新增', bclass: 'add', onpress: toolbarItem },
                                { name: 'modify', displayname: '修改', bclass: 'modify', onpress: toolbarItem },
                                { name: 'delete', displayname: '删除', bclass: 'delete', onpress: toolbarItem },
                                {
                                    separator: true
                                }
                             ],
                 searchitems: [
                    { display: 'Name', name: 'Name' }
                    ],
                 sortname: 'Id',
                 sortorder: 'asc',
                 usepager: true,
                 title: 'Customers',
                 useRp: true,
                 rp: 15,
                 showTableToggleBtn: true,
                 pagestat: '显示 {from} 到 {to}， 共 {total} 条',
                 nomsg: '没有数据',
                 procmsg: '请等待数据正在加载中…',
                 width: 500,
                 height: 380,
                 singleSelect: true//只能单选 
             }
              );
              function toolbarItem(com, grid) {
                  if (com == 'delete') {
                      if ($('.trSelected', grid).length == 0) {
                          alert("请选择要删除的数据"  );
                      } else {
                          if (confirm('是否删除这 ' + $('.trSelected', grid).length + ' 条记录吗?' )) {
                              var ids = "";
                              for (var i = 0; i < $('.trSelected', grid).length; i++) {
                                  ids += "," + $('.trSelected', grid).find("td:eq(2)").eq(i).text(); //获取id,td:eq(2)
                                  alert(ids);
                              }
                              ids = ids.substring(1);
                              $.ajax({
                                  type: "POST",
                                  url: '/FunctionItems/GetDetailsFunctionesGroup',
                                  data: "id=" + ids,
                                  dataType: "text",
                                  success: function(msg) {
                                      if (msg == "success") {
                                          $("#customers").flexReload();
                                      } else {
                                          alert("有错误发生,msg=" + msg);
                                      }
                                  },
                                  error: function(msg) {
                                  alert("有错误发生msg=有错误发生" + msg);
                                  }
                              });
                          }
                      }
                  } else if (com == 'add') {
                  alert("flexGridServlet.do?action=add");
//                  $("#Div1").dialog
//                      $("#Div1").dialog("open"); 
                   
                  } else if (com == 'modify') {
                      if ($(".trSelected").length == 1) { 
                          var data = new Array();
                          $('.trSelected td', grid).each(function(i) {
                              data[i] = $(this).children('div').text(); 
                          });
                          alert(data[0]); 
                          //  alert(data);   读取GRID中的值s
                          // 初始化编辑数据界面数据
                          $.ajax({
                              url: '/FunctionItems/GetDetailsFunctionesGroup',
                              data: {},
                              type: 'GET',
                              dataType: 'json',
                              success: function(data) {
                                  //     alert(data); 
                                  alert('Success');
                                  // $("#Div1").dialog
                                  //$("#Div1").dialog("open");  
                              }
                          });
                          //$('#Div1').dialog('open');  
                      } else if ($(".trSelected").length > 1) {
                          alert("请选择一个修改,不能同时修改多个");
                      } else if ($(".trSelected").length == 0) {
                          alert("请选择一个您要修改的记录")
                      }
                      //$("#flex1").flexReload({});  
                  }
              }
              
        </script> 
                    </div>
                    <div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
